var app = getApp();
Page({
    data:{
        siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
        vedio : {},
        fee : '',
        inited : false,
    },
    onLoad:function(options){
        var self = this;
        var code = options.code ? options.code : (options.scene ? options.scene : '');
        var postdata = {
            op:'mcode',
            code : code,
            zfid : options.zfid ? options.zfid : '',
        };
        self.data.options = options;

        app.com.auth(function(user){
            app.com.http('user_v1','POST',postdata,0,false,'','',function(res){
                if (!res.data.errno && res.data) {
                    self.setData({
                        params : res.data.data.params,
                        info : res.data.data.info,
                        inited : true,
                    })
                    
                    wx.setNavigationBarTitle({
                        title: res.data.data.params.umname+'码'
                    });
                    
                }else{
                    app.com.alert(res.data.message,function(){
                        app.com.backPage(0);
                    });
                }
            });
        })
    },
    onPullDownRefresh: function () {
        if( this.data.isdown ) return false;
        this.data.isdown = true;
        this.onLoad(this.data.options);
        this.data.isdown = false;
        wx.stopPullDownRefresh();
    },
    dealit(e){
        var self = this;
        if(self.data.info.status == 0){
            var postdata = {
                op : 'passbycode',
                code : self.data.info.code,
            };
            app.com.http('user_v1','POST',postdata,0,true,'','',function(res){
                app.com.alert(res.data.message);
                if (!res.data.errno && res.data) {
                    self.setData({
                        'info.status' : 1,
                        'info.tips' : '',
                        'info.desc' : '已经使用',
                        'info.btnstr' : '返回首页',
                    })
                }
            });
        }else{
            self.navigateto(e);
        }
    },
    onChangetime(e){
        this.data.toptime = e.detail;
        this.countTotal();
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    authed(){
        this.setData({
            isauth : false,
        })
        this.pub();
    }
})